import request from '@/utils/request'
import { Complaint } from './type'
import { BaseResponse, BasePageReq } from '../base'

export function pageQuery(params: BasePageReq): Promise<BaseResponse> {
  return request({ url: '/campus/complaint/page', method: 'get', params })
}
export function pageQueryMe(params: BasePageReq): Promise<BaseResponse> {
  return request({ url: '/campus/complaint/pageMe', method: 'get', params })
}

export function getComplaint(id: number): Promise<BaseResponse> {
  return request({ url: `/campus/complaint/detail/${id}`, method: 'get' })
}

export function agree(id: number): Promise<BaseResponse> {
  return request({ url: `/campus/complaint/agree/${id}`, method: 'post' })
}

export function disagree(id: number): Promise<BaseResponse> {
  return request({ url: `/campus/complaint/disagree/${id}`, method: 'post' })
}

export function addComplaint(data: Complaint): Promise<BaseResponse> {
  return request({ url: '/campus/complaint/add', method: 'post', data })
}

export function deleteComplaint(id: number): Promise<BaseResponse> {
  return request({ url: `/campus/complaint/delete/${id}`, method: 'delete' })
}

export function updateStatus(id: number, status: number): Promise<BaseResponse> {
  return request({ url: `/campus/complaint/updateStatus?id=${id}&status=${status}`, method: 'put' })
}

export function update(data: Complaint): Promise<BaseResponse> {
  return request({ url: `/campus/complaint/update`, method: 'put', data })
}
export function pageMyOpt(params: BasePageReq): Promise<BaseResponse> {
  return request({ url: `/campus/complaint/pageMyOpt`, method: 'get', params })
}